window.onload = function () {
    window.vue = new Vue({
        el: '#my-div',
        data: {
            list: [],
            callStack: [],
            index: -1,
            sValue: '',
            page: 1,
            total: 0,
            pageSize: 15,
        },
        methods: {
            find: function () {
                if (this.callStack.length > 0) {
                    return;
                }
                doGet({
                    url: 'developer/log/query_log',
                    data: {
                        condition: vue.sValue,
                        page: vue.page,
                        page_size: vue.pageSize,
                    },
                    callback: function (res) {
                        if (res.data.code === 1) {
                            let result = res.data.data;
                            vue.list = result.data;
                            if (vue.page === 1) {
                                vue.total = result.total;
                                window.paginationVue.setPageCount(Math.ceil(vue.total / vue.pageSize));
                                window.paginationVue.setTotal(vue.total);
                            }
                            $('#table-main')[0].style.visibility = 'visible';
                        }
                        else {
                            console.log(res);
                        }
                    }
                });
            },
            openLog: function () {
                doPost({
                    url: 'developer/log/open_log',
                    callback: function (res) {
                        if (res.data.code === 0) {
                            window.parent.showInfo('操作失败');
                        }
                    }
                });
            },
            closeLog: function () {
                doPost({
                    url: 'developer/log/close_log',
                    callback: function (res) {
                        if (res.data.code === 0) {
                            window.parent.showInfo('操作失败');
                        }
                    }
                });
            },
            clearLog: function () {
                doPost({
                    url: 'developer/log/clear_console_log',
                    callback: function (res) {
                        if (res.data.code === 0) {
                            window.parent.showInfo('操作失败');
                        }
                        else {
                            vue.queryLog();
                        }
                    }
                });
            },

        },
        watch: {
            sValue(cur, old) {
                this.sValue = trim(cur);
                localStorage['condition_console'] = this.sValue;
            }
        }

    });
    vue.sValue = getLocalStorage('condition_console', '');
    vue.find();

    $('#filter').on('keydown', function (res) {
        if (res.keyCode === 13) {
            vue.find();
        }
    });

    includeHTML('pagination_view', function (code, msg) {
        if (code === 200) {
            window.paginationVue.onPageValueChanged = function (page) {
                vue.page = page;
                vue.find();
            };
        } else {
            log(msg);
        }
    });

};
